package com.ViewModel;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;



public class ImageAdapter extends BaseAdapter {

	public Integer[] imagesIds ={
		    R.drawable.food,
		    R.drawable.sup
			};
			
	private Context context;
	
	public ImageAdapter(Context applicationContext) {
		// TODO Auto-generated constructor stub
	context= applicationContext;
	}

	public int getCount() {
		// TODO Auto-generated method stub
		return imagesIds.length;
	}

	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ImageView iv;
		if(convertView!=null)
		{
			iv=(ImageView)convertView;
		}
		else
		{
			iv= new ImageView(context);
			iv.setLayoutParams(new GridView.LayoutParams(80,80));
			iv.setScaleType(ScaleType.CENTER_CROP);
			iv.setPadding(8, 8, 8, 8);
			
		}
		iv.setImageResource(imagesIds[position]);
		
		
		return iv;
	}

}
